<html>  
<head>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<link href="prawn.css" rel="stylesheet" type="text/css" />
<link href="twilight.css" rel="stylesheet" type="text/css" />
</head>
<body> 

<div id="contents">
  <ul>                                                        
    <li><a href="docs/">Docs</li>
    <li><a href="http://prawn.lighthouseapp.com">Bugs</a></li>
    <li><a href="http://groups.google.com/group/prawn-ruby">Community</a></li>
    <li><a href="http://github.com/sandal/prawn">Source</a></li>    
  </ul>

<h1><i>Prawn: Fast, Nimble PDF Generation For Ruby</i></h1>
<span style="color:ffffff; font-size: 0.8em">
<b>Installable via <u><a href="http://rubygems.org">RubyGems</a></u> :&nbsp; <tt>gem install prawn</tt></b>  
<br> 
</span>  

<div align="right">
  <br><a href="/prawn-Chinese.html">中文界面</a>
</div>

<h2>Building printable documents doesn't have to be hard</h2> 
<img src="media/prawn_logo.png" style="float: right;">
<p>
   If you've ever needed to produce PDF documents before, in Ruby or another language, you probably know how much it can suck.  <span style="color: #2299ff"><b><i>Prawn takes the pain out of generating beautiful printable documents</b></i></span>, while still remaining fast, tiny and nimble.  It is also named after a majestic sea creature, and that has to count for something.     
</p>
<h2>The features you need, without all the complexity</h2>
   
<p>
In addition to being the <span style="color: #2299ff"><i><b>fastest pure Ruby PDF generation library</i></b></span>, Prawn has features that might prevent you from hating your job.  The samples below give
a taste of what Prawn based programs looks like, <span style="color: #2299ff"><b><i>click the code to reveal the PDF it generates.</i></b></span>
</p>  
                                                                     
<h3>-- Built in support for UTF-8</h3>
    
<p>
Internationalized text in Prawn is as simple as providing UTF-8 strings for it to render, assuming you've got a Unicode aware TTF font handy.  For those who are running on Ruby 1.9, any encoding that can be converted to UTF-8 will work out of the box!
</p>     

<a href="media/utf8.pdf">
<!-- begin dump from pastie.org/311073 -->
		<pre class="textmate-source"><pre class="sunburst"><span class='support support_class support_class_ruby'>Prawn</span><span class='meta meta_function-call meta_function-call_method meta_function-call_method_without-arguments meta_function-call_method_without-arguments_ruby'>::<span class='entity entity_name entity_name_function entity_name_function_ruby'>Document</span></span><span class='meta meta_function-call meta_function-call_method meta_function-call_method_with-arguments meta_function-call_method_with-arguments_ruby'>.<span class='entity entity_name entity_name_function entity_name_function_ruby'>generate</span></span>(<span class='string string_quoted string_quoted_double string_quoted_double_ruby'>&quot;utf8.pdf&quot;</span>) <span class='keyword keyword_control keyword_control_ruby keyword_control_ruby_start-block'>do</span>
  font <span class='string string_quoted string_quoted_double string_quoted_double_ruby'>&quot;<span class='source source_ruby source_ruby_embedded source_ruby_embedded_source'>#{<span class='support support_class support_class_ruby'>Prawn</span><span class='meta meta_function-call meta_function-call_method meta_function-call_method_without-arguments meta_function-call_method_without-arguments_ruby'>::<span class='entity entity_name entity_name_function entity_name_function_ruby'>BASEDIR</span></span>}</span>/data/fonts/DejaVuSans.ttf&quot;</span>
  text <span class='string string_quoted string_quoted_double string_quoted_double_ruby'>&quot;ὕαλον ϕαγεῖν δύναμαι· τοῦτο οὔ με βλάπτει.&quot;</span> <span class='keyword keyword_operator keyword_operator_arithmetic keyword_operator_arithmetic_ruby'>*</span> <span class='constant constant_numeric constant_numeric_ruby'>20</span>
<span class='keyword keyword_control keyword_control_ruby'>end</span>
</pre></pre>

<!-- end pastie dump -->
</a>

<h3>-- Easy image embedding</h3>
  
<p>
Prawn makes embedding JPEG and PNG images a breeze.  With support for alpha transparency, easy positioning and scaling of images, you'll have no problem
including all the graphics you need in your documents.
</p>  

<a href="media/image.pdf">

<!-- begin dump from pastie.org/311068 -->

		<pre class="textmate-source"><pre class="sunburst"><span class='support support_class support_class_ruby'>Prawn</span><span class='meta meta_function-call meta_function-call_method meta_function-call_method_without-arguments meta_function-call_method_without-arguments_ruby'>::<span class='entity entity_name entity_name_function entity_name_function_ruby'>Document</span></span><span class='meta meta_function-call meta_function-call_method meta_function-call_method_with-arguments meta_function-call_method_with-arguments_ruby'>.<span class='entity entity_name entity_name_function entity_name_function_ruby'>generate</span></span>(<span class='string string_quoted string_quoted_double string_quoted_double_ruby'>&quot;image2.pdf&quot;</span>, <span class='constant constant_other constant_other_symbol constant_other_symbol_ruby'>:page_layout</span> =&gt; <span class='constant constant_other constant_other_symbol constant_other_symbol_ruby'>:landscape</span>) <span class='keyword keyword_control keyword_control_ruby keyword_control_ruby_start-block'>do     </span>
  pigs <span class='keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby'>=</span> <span class='string string_quoted string_quoted_double string_quoted_double_ruby'>&quot;<span class='source source_ruby source_ruby_embedded source_ruby_embedded_source'>#{<span class='support support_class support_class_ruby'>Prawn</span><span class='meta meta_function-call meta_function-call_method meta_function-call_method_without-arguments meta_function-call_method_without-arguments_ruby'>::<span class='entity entity_name entity_name_function entity_name_function_ruby'>BASEDIR</span></span>}</span>/data/images/pigs.jpg&quot;</span> 
  image pigs, <span class='constant constant_other constant_other_symbol constant_other_symbol_ruby'>:at</span> =&gt; [<span class='constant constant_numeric constant_numeric_ruby'>50</span>,<span class='constant constant_numeric constant_numeric_ruby'>450</span>], <span class='constant constant_other constant_other_symbol constant_other_symbol_ruby'>:width</span> =&gt; <span class='constant constant_numeric constant_numeric_ruby'>450</span>                                      

  dice <span class='keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby'>=</span> <span class='string string_quoted string_quoted_double string_quoted_double_ruby'>&quot;<span class='source source_ruby source_ruby_embedded source_ruby_embedded_source'>#{<span class='support support_class support_class_ruby'>Prawn</span><span class='meta meta_function-call meta_function-call_method meta_function-call_method_without-arguments meta_function-call_method_without-arguments_ruby'>::<span class='entity entity_name entity_name_function entity_name_function_ruby'>BASEDIR</span></span>}</span>/data/images/dice.png&quot;</span>
  image dice, <span class='constant constant_other constant_other_symbol constant_other_symbol_ruby'>:at</span> =&gt; [<span class='constant constant_numeric constant_numeric_ruby'>50</span>, <span class='constant constant_numeric constant_numeric_ruby'>450</span>], <span class='constant constant_other constant_other_symbol constant_other_symbol_ruby'>:scale</span> =&gt; <span class='constant constant_numeric constant_numeric_ruby'>0.75</span> 
<span class='keyword keyword_control keyword_control_ruby'>end</span>
</pre></pre>

<!-- end pastie dump -->

</a>

<h3>-- Flexible table drawing</h3>

<p>
Prawn has built in support for rendering text in the form of tables, providing
basic reporting functionality.  This lets users focus on customizing their 
documents rather than forcing them to write a ton of low level graphics drawing
code.
</p>   

<a href="media/fancy_table.pdf">
<!-- begin dump from pastie.org/311075 -->  

		<pre class="textmate-source"><pre class="sunburst"><span class='support support_class support_class_ruby'>Prawn</span><span class='meta meta_function-call meta_function-call_method meta_function-call_method_without-arguments meta_function-call_method_without-arguments_ruby'>::<span class='entity entity_name entity_name_function entity_name_function_ruby'>Document</span></span><span class='meta meta_function-call meta_function-call_method meta_function-call_method_with-arguments meta_function-call_method_with-arguments_ruby'>.<span class='entity entity_name entity_name_function entity_name_function_ruby'>generate</span></span>(<span class='string string_quoted string_quoted_double string_quoted_double_ruby'>&quot;fancy_table.pdf&quot;</span>) <span class='keyword keyword_control keyword_control_ruby keyword_control_ruby_start-block'>do</span>

  data <span class='keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby'>=</span> [[<span class='string string_quoted string_quoted_double string_quoted_double_ruby'>&quot;Gregory Brown&quot;</span>, <span class='string string_quoted string_quoted_double string_quoted_double_ruby'>&quot;gregory.t.brown@fakemail.test&quot;</span> ],
          [<span class='string string_quoted string_quoted_double string_quoted_double_ruby'>&quot;James Healy&quot;</span>  , <span class='string string_quoted string_quoted_double string_quoted_double_ruby'>&quot;jimmy@fakemail.test&quot;</span>           ],
          [<span class='string string_quoted string_quoted_double string_quoted_double_ruby'>&quot;Ross Perot&quot;</span>   , <span class='string string_quoted string_quoted_double string_quoted_double_ruby'>&quot;ross@fakemail.test&quot;</span>            ],
          [<span class='string string_quoted string_quoted_double string_quoted_double_ruby'>&quot;Al Gore&quot;</span>      , <span class='string string_quoted string_quoted_double string_quoted_double_ruby'>&quot;al@fakemail.test&quot;</span>              ],
          [<span class='string string_quoted string_quoted_double string_quoted_double_ruby'>&quot;Ralph Nader&quot;</span>  , <span class='string string_quoted string_quoted_double string_quoted_double_ruby'>&quot;ralph@fakemail.test&quot;</span>           ]]

  table data,
    <span class='constant constant_other constant_other_symbol constant_other_symbol_ruby'>:position</span>           =&gt; <span class='constant constant_other constant_other_symbol constant_other_symbol_ruby'>:center</span>,
    <span class='constant constant_other constant_other_symbol constant_other_symbol_ruby'>:headers</span>            =&gt; [<span class='string string_quoted string_quoted_double string_quoted_double_ruby'>&quot;Name&quot;</span>, <span class='string string_quoted string_quoted_double string_quoted_double_ruby'>&quot;Email&quot;</span>],
    <span class='constant constant_other constant_other_symbol constant_other_symbol_ruby'>:row_colors</span>         =&gt; [<span class='string string_quoted string_quoted_double string_quoted_double_ruby'>&quot;ffffff&quot;</span>,<span class='string string_quoted string_quoted_double string_quoted_double_ruby'>&quot;ffff00&quot;</span>],
    <span class='constant constant_other constant_other_symbol constant_other_symbol_ruby'>:vertical_padding</span>   =&gt; <span class='constant constant_numeric constant_numeric_ruby'>5</span>,
    <span class='constant constant_other constant_other_symbol constant_other_symbol_ruby'>:horizontal_padding</span> =&gt; <span class='constant constant_numeric constant_numeric_ruby'>3</span>
<span class='keyword keyword_control keyword_control_ruby'>end</span>
</pre></pre>
<!-- end pastie dump -->
</a>   

<h3>-- Simplified content positioning</h3>
                                                        
<p>
Anyone who has done work with a low level graphics engine knows that doing coordinate math isn't fun.  Prawn simplifies this by allowing you to box off a sub-section of the document and treat it as its own mini-coordinate space.  This means that all positioning is relative, making it easy to move things around your document while keeping your code clean.

Text can also be flowed within these sectioned off bounding boxes, so this 
makes it trivial to generate columns of text on the fly.
</p>              

<a href="media/bounding_boxes.pdf">
  <!-- begin dump from pastie.org/311081 -->    
  <pre class="textmate-source"><pre class="sunburst"><span class='support support_class support_class_ruby'>Prawn</span><span class='meta meta_function-call meta_function-call_method meta_function-call_method_without-arguments meta_function-call_method_without-arguments_ruby'>::<span class='entity entity_name entity_name_function entity_name_function_ruby'>Document</span></span><span class='meta meta_function-call meta_function-call_method meta_function-call_method_with-arguments meta_function-call_method_with-arguments_ruby'>.<span class='entity entity_name entity_name_function entity_name_function_ruby'>generate</span></span>(<span class='string string_quoted string_quoted_double string_quoted_double_ruby'>&quot;bounding_boxes.pdf&quot;</span>) <span class='keyword keyword_control keyword_control_ruby keyword_control_ruby_start-block'>do   </span>

  bounding_box [<span class='constant constant_numeric constant_numeric_ruby'>100</span>,<span class='constant constant_numeric constant_numeric_ruby'>600</span>], <span class='constant constant_other constant_other_symbol constant_other_symbol_ruby'>:width</span> =&gt; <span class='constant constant_numeric constant_numeric_ruby'>200</span> <span class='keyword keyword_control keyword_control_ruby keyword_control_ruby_start-block'>do</span>
    text <span class='string string_quoted string_quoted_double string_quoted_double_ruby'>&quot;The rain in spain falls mainly on the plains &quot;</span> <span class='keyword keyword_operator keyword_operator_arithmetic keyword_operator_arithmetic_ruby'>*</span> <span class='constant constant_numeric constant_numeric_ruby'>5</span>
    stroke <span class='keyword keyword_control keyword_control_ruby keyword_control_ruby_start-block'>do</span>
      line bounds<span class='meta meta_function-call meta_function-call_method meta_function-call_method_without-arguments meta_function-call_method_without-arguments_ruby'>.<span class='entity entity_name entity_name_function entity_name_function_ruby'>top_left</span></span>,    bounds<span class='meta meta_function-call meta_function-call_method meta_function-call_method_without-arguments meta_function-call_method_without-arguments_ruby'>.<span class='entity entity_name entity_name_function entity_name_function_ruby'>top_right</span></span>
      line bounds<span class='meta meta_function-call meta_function-call_method meta_function-call_method_without-arguments meta_function-call_method_without-arguments_ruby'>.<span class='entity entity_name entity_name_function entity_name_function_ruby'>bottom_left</span></span>, bounds<span class='meta meta_function-call meta_function-call_method meta_function-call_method_without-arguments meta_function-call_method_without-arguments_ruby'>.<span class='entity entity_name entity_name_function entity_name_function_ruby'>bottom_right</span></span>
    <span class='keyword keyword_control keyword_control_ruby'>end</span>
  <span class='keyword keyword_control keyword_control_ruby'>end</span>

  bounding_box [<span class='constant constant_numeric constant_numeric_ruby'>100</span>,<span class='constant constant_numeric constant_numeric_ruby'>500</span>], <span class='constant constant_other constant_other_symbol constant_other_symbol_ruby'>:width</span> =&gt; <span class='constant constant_numeric constant_numeric_ruby'>200</span>, <span class='constant constant_other constant_other_symbol constant_other_symbol_ruby'>:height</span> =&gt; <span class='constant constant_numeric constant_numeric_ruby'>200</span> <span class='keyword keyword_control keyword_control_ruby keyword_control_ruby_start-block'>do</span>
    stroke <span class='keyword keyword_control keyword_control_ruby keyword_control_ruby_start-block'>do</span>
      circle_at [<span class='constant constant_numeric constant_numeric_ruby'>100</span>,<span class='constant constant_numeric constant_numeric_ruby'>100</span>], <span class='constant constant_other constant_other_symbol constant_other_symbol_ruby'>:radius</span> =&gt; <span class='constant constant_numeric constant_numeric_ruby'>100</span>
      line bounds<span class='meta meta_function-call meta_function-call_method meta_function-call_method_without-arguments meta_function-call_method_without-arguments_ruby'>.<span class='entity entity_name entity_name_function entity_name_function_ruby'>top_left</span></span>, bounds<span class='meta meta_function-call meta_function-call_method meta_function-call_method_without-arguments meta_function-call_method_without-arguments_ruby'>.<span class='entity entity_name entity_name_function entity_name_function_ruby'>bottom_right</span></span>
      line bounds<span class='meta meta_function-call meta_function-call_method meta_function-call_method_without-arguments meta_function-call_method_without-arguments_ruby'>.<span class='entity entity_name entity_name_function entity_name_function_ruby'>top_right</span></span>, bounds<span class='meta meta_function-call meta_function-call_method meta_function-call_method_without-arguments meta_function-call_method_without-arguments_ruby'>.<span class='entity entity_name entity_name_function entity_name_function_ruby'>bottom_left</span></span>
    <span class='keyword keyword_control keyword_control_ruby'>end</span>   

    bounding_box [<span class='constant constant_numeric constant_numeric_ruby'>50</span>,<span class='constant constant_numeric constant_numeric_ruby'>150</span>], <span class='constant constant_other constant_other_symbol constant_other_symbol_ruby'>:width</span> =&gt; <span class='constant constant_numeric constant_numeric_ruby'>100</span>, <span class='constant constant_other constant_other_symbol constant_other_symbol_ruby'>:height</span> =&gt; <span class='constant constant_numeric constant_numeric_ruby'>100</span> <span class='keyword keyword_control keyword_control_ruby keyword_control_ruby_start-block'>do</span>
      stroke_rectangle bounds<span class='meta meta_function-call meta_function-call_method meta_function-call_method_without-arguments meta_function-call_method_without-arguments_ruby'>.<span class='entity entity_name entity_name_function entity_name_function_ruby'>top_left</span></span>, bounds<span class='meta meta_function-call meta_function-call_method meta_function-call_method_without-arguments meta_function-call_method_without-arguments_ruby'>.<span class='entity entity_name entity_name_function entity_name_function_ruby'>width</span></span>, bounds<span class='meta meta_function-call meta_function-call_method meta_function-call_method_without-arguments meta_function-call_method_without-arguments_ruby'>.<span class='entity entity_name entity_name_function entity_name_function_ruby'>height</span></span>
    <span class='keyword keyword_control keyword_control_ruby'>end</span>   
  <span class='keyword keyword_control keyword_control_ruby'>end</span>
<span class='keyword keyword_control keyword_control_ruby'>end</span>
  </pre></pre>

  <!-- end pastie dump -->  
</a>

<h3>-- And loads more to come</h3>

<span style="color: #2299ff"><b><i>Prawn is currently alpha-level software under active development.</i></b></span>  New features are cropping up every day, and we expect to see loads of cool things in the near future including integration with the popular <a href="http://rubyreports.org">Ruby Reports</a> project.  For now, you can keep
an eye on the latest new features by checking out the <a href="http://github.com/sandal/prawn/tree/master/examples">examples distributed
with the source</a>, which include the code samples shown above and much, much more!    

<h2>Supported by the Ruby Community</h2> 

<p>The development on Prawn is in part made possible through donations from the community to 
Gregory Brown's <a href="http://rubymendicant.wikidot.com">Ruby Mendicant</a> project, but quickly outgrew its humble beginnings.</p>  

<p>Since the project began in April 2008, the project has seen contributions in the form of code, bug reports, and feature requests from a whole bunch of Ruby hackers.  You can find many of their contributions by checking out the <a href="http://github.com/sandal/prawn/network">Github
network graph</a> for the project.  Although several have contributed patches to Prawn, special thanks goes out to <b>James Healy</b> and <b>Michael Daines</b> for being instrumental to the forward development of the library.</p>  

<p>Many people have expressed interest in using Prawn within their Rails applications, and for this purpose, you might be interested in checking out yet another community contribution, thorny_sun's <a href="http://cracklabs.com/prawnto">Prawnto</a> Rails plugin.  Although this is not officially part of Prawn, we'll do what we can to make sure this plugin continues to work as things move forward</p>

<p><span style="color: #2299ff"><b><i>Please join us in the development of Prawn so that it can become the library of choice for PDF generation in Ruby.</i></b></span>   You can start by getting in touch with us on the <a href="http://groups.google.com/group/prawn-ruby">mailing list</a> or stopping by to chat in the <tt>#prawn</tt> channel on irc.freenode.net. There is lots left to be done, and we could use your help!</p>
 
<h2>What are you waiting for?</h2>
<p>It's time to generate some PDFs. Get Prawn via RubyGems with <tt>gem install prawn</tt> or clone us at <tt>git://github.com/sandal/prawn.git</tt></p>     

</div>                                                                       

<div align="center">
<small>   
<p>
  Prawn is Free Software under the License of Ruby, developed by <a href="http://majesticseacreature.com" style="color: #2299ff;" >Gregory Brown</a> and the Ruby community.<br/>
  The Prawn logo was created by <a href="">maso</a> and is distributed under
  the <a href="http://creativecommons.org/licenses/by-sa/3.0/" style="color: 2299ff;">CC Attribution-Share Alike</a> license.  
</p>  
</small>             
</div>

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-2193841-4");
pageTracker._trackPageview();
</script>      
</body>  
</html>



